package com.yiyuan.weixin.weixinInservice.format;

import com.yiyuan.weixin.model.ReceiveXmlEntity;
import com.yiyuan.weixin.weixinInservice.format.FormatXmlService;

import java.util.Date;

/**
 * Created by admin on 2017/3/28.
 */
public class FormatXmlText implements FormatXmlService {
//    @Override
//    public String formatXml(ReceiveXmlEntity receiveXmlEntity) {
//        StringBuffer sb = new StringBuffer();
//        Date date = new Date();
//        sb.append("<xml><ToUserName><![CDATA[");
//        sb.append(receiveXmlEntity.getFromUserName());
//        sb.append("]]></ToUserName><FromUserName><![CDATA[");
//        sb.append(receiveXmlEntity.getToUserName());
//        sb.append("]]></FromUserName><CreateTime>");
//        sb.append(date.getTime());
//        sb.append("</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[");
//        sb.append(receiveXmlEntity.getContent());
//        sb.append("]]></Content><FuncFlag>0</FuncFlag></xml>");
//
//        // TODO: 2017/3/28 正式发布交互 收发方
//
//        return sb.toString();
//    }

    @Override
    public String formatXml(ReceiveXmlEntity receiveXmlEntity) {
        StringBuffer sb = new StringBuffer();
        Date date = new Date();
        sb.append("<xml><ToUserName><![CDATA[");
        sb.append(receiveXmlEntity.getFromUserName());
        sb.append("]]></ToUserName><FromUserName><![CDATA[");
        sb.append(receiveXmlEntity.getToUserName());
        sb.append("]]></FromUserName><CreateTime>");
        sb.append(date.getTime());
        sb.append("</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[");
        sb.append(receiveXmlEntity.getContent());
        sb.append("]]></Content><FuncFlag>0</FuncFlag></xml>");

        // TODO: 2017/3/28 正式发布交互 收发方

        return sb.toString();
    }
}
